import { runtimeSubmit } from '@/api/flow/runtime';
import { useAuthStore } from '@/stores/auth/index.jsx';
import { storeToRefs } from 'pinia';
export function commonFlow(options) {
  const { userInfo } = storeToRefs(useAuthStore());
  return new Promise((resolve, reject) => {
    const {
      assignee = userInfo.value.id,
      assigneeName = userInfo.value.realName,
      bizKey,
      callbackUrl,
      flowKey,
      idea = '1',
      ideaMsg = '通过',
      ideaSuggest,
      taskId = 'task1',
      nextAssigneeList = [userInfo.value.id]
    } = options;
    const params = {
      assignee,
      assigneeName,
      bizKey,
      callbackUrl,
      flowKey: flowKey,
      idea,
      ideaMsg,
      ideaSuggest,
      nextAssigneeList,
      taskId
    };
    (async () => {
      try {
        const { code } = await runtimeSubmit(params);
        console.log(code, 'code--->');
        resolve(code);
      } catch (error) {
        reject(error);
      }
    })();
  });
}
